<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<head>
<%@ include file="/common/common-css.jsp"%>
<style>
#jquery-table td {
	cursor: pointer !important
}

.load_bg {
	background: #000;
	opacity: 0.1;
	left: 0px;
	top: 0px;
	position: fixed;
	height: 100%;
	width: 100%;
	overflow: hidden;
	z-index: 10000;
}

.load_img {
	left: 50%;
	top: 180px;
	position: fixed;
	height: 50px;
	overflow: hidden;
	z-index: 20000;
}
</style>
</head>
<body class="no-skin">
	<div class="load_bg" style="display: none;"></div>
	<img src="http://img.xmiles.cn/commentloading.gif" class="load_img"
		style="display: none" />
	<div class="page-content">
		<div class="page-header"
			style="margin-bottom: 0px; padding-bottom: 10px;"></div>

		<form id="queryForm">
			<div class="page-content-area">
				<div class="row">
					<div class="col-sm-12">
						<div class="widget-box"
							style="border: 0px solid #ccc; border-top: none; border-bottom: none;">
							<div class="widget-header widget-header-blue widget-header-flat">
								<h4 class="widget-title">选择条件进行查询</h4>
								<div class="widget-toolbar">
									<a href="#" data-action="collapse"> <i
										class="ace-icon fa fa-chevron-up"></i>
									</a>
								</div>
							</div>
							<div class=" widget-body">
								<div class="widget-main">
									<!-- <div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
								<label class="col-sm-4 control-label"  style="text-align:right"  for="userID">活动ID:</label>
								<div class="col-sm-8" style="padding-left:0;">
									<input type="text" name="activityid" style="width:100%;text-align:left;">
								</div>
							</div>	 -->

									<div class="form-group col-xs-12 col-sm-4 ">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">渠道：</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<s:select headerKey="" headerValue="请选择" name="channel"
												value="%{paramsMap.modelList.channel_code}"
												list="%{paramsMap.modelList}" listKey="channel_code"
												listValue="channel_name" cssClass="form-control"></s:select>
										</div>
									</div>

									<div class="form-group col-xs-12 col-sm-4 ">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">产品：</label>
										<div class="col-sm-8" style="padding-left: 0;">
										<select name="prdid">
											  <option value="8006">联登外部页</option>
											  <option value="8008">外推api投递页</option>
											  <option value="8009">联登备用渠道1</option>
											  <option value="8010">联登备用渠道2</option>
											  <option value="8011">联登备用渠道3</option>
										</select>
										</div>
									</div>

									<div class="form-group col-xs-12 col-sm-4 ">
										<label class="col-sm-2 control-label"
											style="text-align: right" for="sex">时间：</label>
										<div class="col-sm-6">
											<div class="input-daterange input-group col-sm-12">
												<input type="text" data-date-format="yyyy-mm-dd"
													class="fromDate date-picker input-sm form-control"
													style="padding-left: 0px" name="cdate"> 
											</div>
										</div>
									</div>
									<div class="form-group col-xs-12 col-sm-4 ">
										<label class="col-sm-4 control-label"
											style="text-align: right" for="isprize">页面：</label>
										<div class="col-sm-8" style="padding-left: 0;">
										<select name="pagefrom">
											  <option value="0">联登外部页老（funid=35）</option>
											  <option value="1">联登外部页新（funid=42）</option>
											  <option value="2">外推api投递页</option>
											  <option value="3">联登备用渠道1</option>
											  <option value="4">联登备用渠道2</option>
											  <option value="5">联登备用渠道3</option>
										</select>
										</div>
									</div>

								</div>
							</div>
						</div>
					</div>
					<div class="col-md-12 center">
						<div class="clearfix form-actions">

							<button class="btn btn-purple  no-border" type="button"
								name="btn-query" onclick="query_any()" id="btn-query">
								<i class="ace-icon fa fa-search icon-on-right bigger-110"></i>
								查询
							</button>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<table id="jquery-table"
							class="table table-striped table-bordered table-hover">
						</table>
					</div>
				</div>
			</div>
		</form>
	</div>

	<%@ include file="/common/common-js.jsp"%>
	<script type="text/javascript" src="${ctx}/js/call_func.js"></script>
	<script type="text/javascript"
		src="${ctx}/ace/js/jquery.dataTables.min.js"></script>
	<script type="text/javascript">
		var souceList = null;

	function trim(str){ //删除左右两端的空格
 		return str.replace(/(^\s*)|(\s*$)/g, "");
	}
	 
		//【查询】按钮Click事件
		function query_any() {
			$(".load_bg").removeAttr("style");
			$(".load_img").removeAttr("style");
			if (jqTable != null) {
				jqTable.fnDraw();
			} else {
				loaddata();
			}
		}
		var jqTable = null;
		var loaddata = function() {
			jQuery(function($) {
				jqTable = $('#jquery-table')
						.dataTable(
								{
									"columnDefs" : [ {
										"title" : "名称",
										"name" : "name",
										"data" : "name",
										"targets" : [ 1 ],
										"bSortable" : true,
										"width" : "10%"
									}, {
										"title" : "渠道",
										"name" : "channel",
										"data" : "channel",
										"targets" : [ 2 ],
										"bSortable" : true,
										"width" : "10%"
									}, {
										"title" : "个数",
										"name" : "count",
										"data" : "count",
										"targets" : [ 3 ],
										"bSortable" : true,
										"width" : "10%"
									}, {
										"title" : "日期",
										"name" : "cdate",
										"data" : "cdate",
										"targets" : [ 0 ],
										"bSortable" : true,
										"width" : "10%"
									} ],
									"sAjaxSource" : ctx
											+ "/oneUnion/getfirstlist.action",
									"fnServerData" : function(sSource, aoData,
											fnCallback) {//从服务器请求数据
										var data = $('#queryForm')
												.serializeObject();
										data.aoData = JSON.stringify(aoData);
										$.ajax({
											"dataType" : 'json',
											"type" : "POST",
											"url" : sSource,
											"data" : data,
											"success" : function(resp) {
												$(".load_bg").attr("style",
														"display:none");
												$(".load_img").attr("style",
														"display:none");
												$("#hidden_pass").attr("style",
														"display:block");
												$('#jquery-table').removeClass(
														"dataTable");
												fnCallback(resp);
												initListPage();
											},
											"error" : function(XMLHttpRequest,
													textStatus, errorThrown) {
												$(".load_bg").attr("style",
														"display:none");
												$(".load_img").attr("style",
														"display:none");
												alert('请求服务器错误,请刷新重试！！');//错误提示，包括服务器重启导致的session失效

											}
										});
									},
									"bDestroy" : true,
									"bScrollInfinite" : true,
									"sScrollXInner" : "100%",
									"sScrollY" : "100%",//如果不设置，IE会有问题
									"aaSorting" : [ [ 0, "desc" ] ]
								//初始化加载，默认按第几列排序、排序方式（列从0开始计算）
								});
			});
		}
		
		function CurentTime(){ 
	        var   today=new   Date();      
	        var   yesterday_milliseconds=today.getTime()-1000*60*60*24;    
	   
	        var   yesterday=new   Date();      
	        yesterday.setTime(yesterday_milliseconds);      
	            
	        var strYear=yesterday.getFullYear(); 
	   
	        var strDay=yesterday.getDate();   
	        var strMonth=yesterday.getMonth()+1; 
	   
	        if(strMonth<10)   
	        {   
	            strMonth="0"+strMonth;   
	        }  
	        if(strDay<10)   
	        {   
	            strDay="0" + strDay;   
	        } 
	        var strYesterday=strYear+"-"+strMonth+"-"+strDay;   
	   		 return(strYesterday); 
	} 


		$(document).ready(function() {
			query_any();
			$(".date-picker").datepicker({
				autoclose : true,
				format : 'yyyy-mm-dd'
			});
			$("#channel").combobox();
			var fullTime = CurentTime();
			$('.fromDate').val(fullTime);
		});
	</script>

</body>
</html>